%partial
%parsertype MyParser


%namespace myCompiler
%{
    private void AddMessage(string message)
    {
        CompilerWorker.GetInstance().AddMessage(message);
    }
%}

%start Program

%union {
	public string str;
	public Double num;
	public string valname;
	public BasicAction action;
}

%type <action> Action

%token DIGIT RAWSTRING NR 
%token SETSTRING
%token SETNUMBER
%token STRINGVAL
%token SEMICOLON
%token SCREENOUT

%%

Program    : Instructions EOF
           | error Instructions
           ;

Instructions   : Instructions Action {InsertAction($1,$2);}
               | Instructions error
               |
               ;

Action   : SETSTRING RAWSTRING STRINGVAL SEMICOLON { AddMessage("set string action"); $$=new SetStringAction($2,$3); } 
         | SETNUMBER RAWSTRING DIGIT SEMICOLON {AddMessage("set number action");$$=new SetNumberAction($2,$3);}
         | SCREENOUT STRINGVAL SEMICOLON {AddMessage("screen out action for pure string");$$=new ScreenOutAction($2);}
         | SCREENOUT RAWSTRING SEMICOLON {AddMessage("screen out action for variable");$$=new ScreenOutValAction($2);}
         ;

%%

 public MyParser(Scanner scanner) : base(null) { base.Scanner = scanner; }